package com.xyh.staservice.controller;


import com.xyh.commonutils.R;
import com.xyh.staservice.client.UcenterClient;
import com.xyh.staservice.service.StatisticsDailyService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-08-17
 */
@RestController
@RequestMapping("/staservice/sta")
//@CrossOrigin
public class StatisticsDailyController {

    @Resource
    private StatisticsDailyService statisticsDailyService;

    //统计某一天的注册人数
    @PostMapping("/registerCount/{day}")
    public R registerCount(@PathVariable("day") String day){
        statisticsDailyService.registerCount(day);
        return R.ok();
    }

    //图表显示，返回两部分数据，日期 json 格式，数量 json 格式
    @GetMapping("/showData/{type}/{begin}/{end}")
    public R showData(@PathVariable("type") String type,@PathVariable("begin") String begin,
                      @PathVariable("end") String end){
        Map<String,Object> map = statisticsDailyService.getShowData(type,begin,end);
        return R.ok().data(map);
    }
}

